package com.example.categorygroup.model;

import com.example.categorygroup.data.Api;
import com.example.categorygroup.data.CategoryValuesEntity;
import com.example.categorygroup.data.CategroyEntity;
import com.example.mvvmcommon.mvvm.model.BaseModel;
import com.example.networkmoudel.ChangeFunction;
import com.example.networkmoudel.HttpFactory;
import com.example.networkmoudel.HttpType;
import com.example.networkmoudel.entity.BaseEntity;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import io.reactivex.Observable;

public class CategoryModel extends BaseModel {

    private String[] names={"电脑办公","手机数码","男装","女装","家用电器","家用电器","家用电器","家用电器","家用电器","家用电器","家用电器","家用电器"};
    public Observable<BaseEntity>requestCategory(Map<String,Object>map){
        return HttpFactory.getInstance().factory(HttpType.TOKENSIGNTYPE).getRetrofit()
                .create(Api.class)
                .requestCategory(cteateBody(map))
                .map(new ChangeFunction<CategoryValuesEntity>());
    }

    public List<CategroyEntity> requestCategroy(){
        List<CategroyEntity> list=new ArrayList<>();
        for (int i = 0; i < names.length; i++) {
            list.add(new CategroyEntity(i,names[i]));
        }
        list.get(0).selFlag=true;
        return list;
    }

}
